package huixue.cn.com.rxapp.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

import huixue.cn.com.rxapp.R;

/**
 * Created by gongdongyang 2019/8/14
 * Describe:
 */
public class BigImageView extends View {

    private Bitmap mBitmap;

    public BigImageView(Context context) {
        this(context,null);
    }

    public BigImageView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,-1);
    }

    public BigImageView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        //获取自定义属性
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.BigImage);
        //array.get
        int resId = array.getResourceId(R.styleable.BigImage_img,0);
        mBitmap = BitmapFactory.decodeResource(getResources(),resId);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawBitmap(mBitmap,0,0,null);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int specMode = MeasureSpec.getMode(widthMeasureSpec);

        int specWidthSize = MeasureSpec.getSize(widthMeasureSpec);
    }
}
